package logic

import (
	"context"
	"errors"
	"user_srv/models"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateExamineStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateExamineStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateExamineStatusLogic {
	return &UpdateExamineStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateExamineStatusLogic) UpdateExamineStatus(in *user.UpdateExamineStatusRequest) (*user.UpdateExamineStatusResponse, error) {
	// todo: add your logic here and delete this line
	var name models.RealName
	name.ID = uint(in.RealId)
	name.Status = in.Status
	err := name.UpdateExamine(in.RealId, in.Status)
	if err != nil {
		logx.Info("更新审核状态失败", err)
		return nil, errors.New("更新审核状态失败")
	}
	return &user.UpdateExamineStatusResponse{}, nil
}
